package com.shuqing.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @program: ShuqingLibrary
 * @ClassName SpringConfig
 * @description:
 * @author: Ats
 * @create: 2025-03-31 09:29
 * @Version 1.0
 */
@Configurable
@Import({MyBatisConfig.class, JdbcConfig.class})
@ComponentScan(value = "com.shuqing.service")
@EnableTransactionManagement
public class SpringConfig {

    @Bean("transactionManager")
    public DataSourceTransactionManager getDataSourceTxManager(
            @Autowired DataSource dataSource){
        DataSourceTransactionManager dtm = new DataSourceTransactionManager();
        dtm.setDataSource(dataSource);
        return dtm;

    }
}
